package ace.cmp.spring.data.jdbc.test.dao.repository;

import ace.cmp.spring.data.jdbc.test.dao.entity.CASUser;
import ace.cmp.spring.data.jdbc.test.dao.mapper.CASUserMapper;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 * @author caspar
 * @date 2023/2/10 17:28 spring data 常用接口
 */
@Slf4j
@AllArgsConstructor
public class CASUserRepositoryExImpl implements CASUserRepositoryEx {
  private final JdbcTemplate jdbcTemplate;
  private final CASUserMapper casUserMapper;

  @Override
  public List<CASUser> findCustomAll() {
    log.info("{}", casUserMapper);

    return jdbcTemplate.query("SELECT * FROM cas_user", new BeanPropertyRowMapper<>(CASUser.class));
  }

  @Override
  public List<CASUser> findMybatisTopByMobileLike(String mobile) {
    return casUserMapper.findAllByMobileLike(mobile);
  }
}
